import Page
from Page import Personal
from Base.Base import Base
from selenium.webdriver.common.by import By


class PersonalForgetPasswordPage(Base):
    """
    忘记密码页面
    """

    # TODO: 钥匙绑定后的状态未遍历(解除绑定>绑定)

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 左侧的home键
        self.password_home_btn = (By.XPATH, Personal.RESOURCE_ID.format("ivHome"))

        # 左侧的返回键
        self.password_back_btn = (By.XPATH, Personal.RESOURCE_ID.format('ivBack'))

        # 手机验证标题
        self.password_iphone_title_text = (By.XPATH, Personal.RESOURCE_ID.format("login_title"))

        # 手机号标题名称
        self.password_iphone_number_title_text = (By.XPATH, Personal.RESOURCE_ID.format("textView5"))

        # 手机号名称
        self.password_iphone_number_text = (By.XPATH, Personal.RESOURCE_ID.format("phone"))

        # 验证码标题
        self.password_captcha_title_text = (By.XPATH, Personal.RESOURCE_ID.format("textView7"))

        # 验证码输入栏
        self.password_captcha_input = (By.XPATH, Personal.RESOURCE_ID.format("verify_code"))

        # 发送验证码
        self.password_send_verification_code_btn = (By.XPATH, Personal.RESOURCE_ID.format("get_verify"))

        # 下一步按钮
        self.password_next_step_btn = (By.XPATH, Personal.RESOURCE_ID.format("login"))

    def click_home(self):
        """
        点击左侧的home键

        :return:None
        """
        self.click_element(self.password_home_btn)

    def click_back(self):
        """
        点击左侧的back键

        :return:None
        """
        self.click_element(self.password_home_btn)

    def get_iphone_title(self):
        """
        获取手机验证标题

        :return: 元素对象
        """
        return self.find_element_o(self.password_iphone_title_text)

    def get_iphone_number_title(self):
        """
        获取手机号标题名称

        :return: 元素对象
        """
        return self.find_element_o(self.password_iphone_number_title_text)

    def get_iphone_number(self):
        """
        获取手机号名称

        :return: 元素对象
        """
        return self.find_element_o(self.password_iphone_number_text)

    def get_captcha_title(self):
        """
        获取验证码标题

        :return: 元素对象
        """
        return self.find_element_o(self.password_captcha_title_text)

    def input_captcha(self, text):
        """
        验证码输入框

        :return: 元素对象
        """
        self.input_text(self.password_captcha_input, text)

    def click_send_verification_code(self):
        """
        点击发送验证码

        :return: None
        """
        self.click_element(self.password_send_verification_code_btn)

    def click_next_step(self):
        """
        点击下一步按钮

        :return: None
        """
        self.click_element(self.password_next_step_btn)

    def is_display_personal_forget_password(self):
        """
        是否进入忘记密码界面

        :return: bool
        """
        return self.is_display(self.password_next_step_btn)
